//7.3 - Pirate Town (7-3PirateTown.cpp) - Dirk Henkemans //Prima Publishing #include #include #include "MenuUtility.h" #include "7-3PirateTown.h" using namespace std; //includes our menu utility into the global namespace using menuNamespace::menu; //the code //handles everything at the wharf namespace wharf { void menu() { string options[] = {"Jump In the Water", "Grab a rowboat and row into the sunset.", "Board the BloodWind.", "Head into town"}; int userResponse = ::menu(options, 4); switch(userResponse) { case 1: cout << "You jump in to the water. Suddenly you \n" <<"hear laughing and realize that you forgot \n" <<"to take off your clothes. You emerge \n" << "from the water sopping wet. \n" ; menu(); break; case 2: cout << "You grab a little red dingy and row off \n" <<"into the sunset. Oh the glory." << endl; break; case 3: cout << "You re-board the BloodWind and wait for \n" <<"your mates to return after having fun. \n"; break; case 4: street::menu(); break; } } } //handles the tavern scene namespace tavern { void menu(void) { string options[] = {"Order a Drink", "Start a rowdy brawl.", "Walk back into the street."}; int userResponse = ::menu(options, 3); switch(userResponse) { case 1: cout << "You order a drink call \"Mikes\"\n"; menu(); break; case 2: cout << "You start a nice rowdy fight.\n"; menu(); break; case 3: street::menu(); break; } } } //handles everything that happens in the street namespace street { void menu(void) { string options[] = {"Head to the wharf", "Enter the tavern.", "Enter the weapons shop.", "Start a fight."}; int userResponse = ::menu(options, 4); switch(userResponse) { case 1: wharf::menu(); break; case 2: tavern::menu(); break; case 3: weaponShop::menu(); break; case 4: cout<< "You start a nice healthy brawl in \n" <<"the street.\n"; street::menu(); break; } } } //allows you to buy weapons namespace weaponShop { void menu(void) { string options[] = {"Buy a jewel encrusted dagger for 300.", "Buy the beautiful flint-lock musket for 300", "Buy a standard English fighting saber for 100", "Leave the shop."}; int userResponse = ::menu(options, 4); switch(userResponse) { case 1: cout << "You purchase a dagger and slip it into\n" <<"you pocket after paying the scrawny man \n" <<"across the counter \n"; menu(); break; case 2: cout << "After paying for the musket you try it\n" <<"out and it works perfectly!!! \n"; menu(); break; case 3: cout << "After taking it for a couple test swings \n" <<"you realize that it wasn't even worth the \n" <<"gold you paid for it \n"; menu(); break; case 4: street::menu(); break; } } } //starts the game int main( void ) { cout<< "Your ship, the BloodWind docks in St. Marie. \n" <<"You get off the ship and are standing on the \n" <<"wharf. \n \n"; wharf::menu(); return 0; }